import React, { Component } from 'react';
import {
  StyleSheet,
  View
} from 'react-native';

import { Colors } from 'react-native/Libraries/NewAppScreen';
import TabNavigator from 'react-native-tab-navigator'
import Search from './components/tabbars/Search'
import Shopcar from './components/tabbars/Shopcar'
import Home from './components/tabbars/Home'
import Me from './components/tabbars/Me'
import Icon from 'react-native-vector-icons/FontAwesome';
class App extends Component {
  constructor(props) {
    super(props)
    this.state = {
      selectedTab: 'home'
    }
  }
  render() {
    return <View style={styles.container}>
    <TabNavigator>
      <TabNavigator.Item
        selected={this.state.selectedTab === 'home'}
        title="Home"
        renderIcon={() => <Icon name="home" size={25} color="gray" />}
        renderSelectedIcon={() => <Icon name="home" size={25} color="#0079FF" />}
        onPress={() => this.setState({ selectedTab: 'home' })}
      >
        <Home></Home>
      </TabNavigator.Item>
      <TabNavigator.Item
        selected={this.state.selectedTab === 'search'}
        title="搜索"
        renderIcon={() => <Icon name="search" size={25} color="gray" />}
        renderSelectedIcon={() => <Icon name="search" size={25} color="#0079FF" />}
        onPress={() => this.setState({ selectedTab: 'search' })}
      >
        <Search></Search>
      </TabNavigator.Item>
      <TabNavigator.Item
        selected={this.state.selectedTab === 'shopcar'}
        title="购物车"
        renderIcon={() => <Icon name="shopping-cart" size={25} color="gray" />}
        renderSelectedIcon={() => <Icon name="shopping-cart" size={25} color="#0079FF" />}
        // renderBadge={() => <CustomBadgeView />}
        badgeText="0"
        onPress={() => this.setState({ selectedTab: 'shopcar' })}
      >
        <Shopcar></Shopcar>
      </TabNavigator.Item>
      <TabNavigator.Item
        selected={this.state.selectedTab === 'me'}
        title="Me"
        renderIcon={() => <Icon name="user" size={25} color="red" />}
        renderSelectedIcon={() => <Icon name="user-o" size={25} color="#0079FF" />}
        // renderBadge={() => <CustomBadgeView />}
        onPress={() => this.setState({ selectedTab: 'me' })}
      >
        <Me></Me>
      </TabNavigator.Item>
    </TabNavigator>
  </View>
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
  scrollView: {
    backgroundColor: Colors.lighter,
  },
  engine: {
    position: 'absolute',
    right: 0,
  },
  body: {
    backgroundColor: Colors.white,
  },
  sectionContainer: {
    marginTop: 32,
    paddingHorizontal: 24,
  },
  sectionTitle: {
    fontSize: 24,
    fontWeight: '600',
    color: Colors.black,
  },
  sectionDescription: {
    marginTop: 8,
    fontSize: 18,
    fontWeight: '400',
    color: Colors.dark,
  },
  highlight: {
    fontWeight: '700',
  },
  footer: {
    color: Colors.dark,
    fontSize: 12,
    fontWeight: '600',
    padding: 4,
    paddingRight: 12,
    textAlign: 'right',
  },
});

export default App;
